package com.onec.service.customer.service.api;

import com.onec.service.api.dto.response.customer.MerchantResp;
import com.onec.service.api.service.customer.MerchantInfoApiService;
import com.onec.service.api.service.notify.NotifyService;
import com.onec.service.customer.entity.merchant.MerchantBusiness;
import com.onec.service.customer.entity.merchant.MerchantInfo;
import com.onec.service.customer.service.MerchantInfoService;
import com.onec.service.customer.service.base.BaseMerchantInfoServiceImpl;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author onec
 */
@DubboService(version = "1.0.1", timeout = 6000)
public class MerchantInfoApiServiceImpl extends BaseMerchantInfoServiceImpl implements MerchantInfoApiService {

    private static final Logger logger = LoggerFactory.getLogger(MerchantInfoApiServiceImpl.class);

    @DubboReference(version = "1.0.1")
    NotifyService notifyService;

    @Autowired
    MerchantInfoService merchantInfoService;

    @Override
    public List<MerchantResp> getListMerchant(int pageNo, int pageSize) {

        logger.info("logger : CustomerInfo:获取商户信息;");
        //List<MerchantInfo> infoList = customerService.getAllListMerchant();
        String s = notifyService.respNotDetail();
        logger.info("logger : notify :获取商户信息,{}", s);
        List<MerchantResp> list = new ArrayList<>();
        return list;
    }

    /**
     * 商户业务等信息：
     *
     * @param customerNo
     * @param businessNo
     * @return
     */
    @Override
    public MerchantResp getMerchantBusiness(String customerNo, String businessNo) {

        MerchantInfo merchantInfo = merchantInfoService.getAvailableMerchant(customerNo);

        MerchantBusiness merchantBusiness = merchantInfoService.getMerchantBusiness(merchantInfo.getId(), businessNo);
        return this.respMerchantInfo(merchantInfo, merchantBusiness);
    }

}
